<template>
	<view>
		<view class="vaccine_detail">
			<view class="vaccine_name">
				<text>{{currentVaccine.vaccineTitle}}</text>
			</view>
			<view class="vaccine_info">
				<text class="vaccine_price">￥{{currentVaccine.price}}</text>
				<!-- <text class="vaccine_date">2020-2-2</text> -->
			</view>
		</view>
		<!-- 时间选择器 -->
		<!-- <uni-section :title="'日期用法：' + single" type="line"></uni-section> -->
		<!-- <view class="example-body">
			<uni-datetime-picker type="date" v-model="datetimesingle" @change="changeLog" hide-second />
		</view> -->
		<view class="vaccine_submit" @click="vaccineSubmit">
			提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				datetimesingle: '',
			}
		},
		computed: {
			currentVaccine() {
				return this.$store.state.m_user.currentVaccine
			}
		},
		methods: {
			vaccineSubmit() {
				// private Integer skipeId; private BigDecimal totalAmount;
				uni.$http.post('/order-server/api/skipe/v1/skipe', {
					skipeId: this.currentVaccine.id,
					totalAmount: this.currentVaccine.price
				}).then(res => {
					console.log(res)
					// confirmToken = res.data.data
					// return Promise.resolve(confirmToken)
				})
				// .then(res => {
				// 	this.commitResgisted(res)
				// })
			},
			// 提交预约
			commitResgisted(confirmToken) {
				uni.$http.post('/order-server/api/order/v1/confirm', {
					"pay_type": "ALIPAY",
					"client_type": "PC",
					"date": this.currentDate,
					"time": this.currentTime,
					"registerId": this.registerId,
					"order_type": "registration",
					"total_amount": this.registrationFee,
					"token": confirmToken
				}).then(res => {
					if (res.statusCode === 200) {
						console.log(res)
						// /api/order/v1/pay  支付接口
						uni.$http.post('/order-server/api/order/v1/pay', {
							'out_trade_no': res.data.data.outTradeNo,
							'payAmount': 3.3
						}).then(res => {
							console.log(res)
							this.getDetailTime()
							uni.navigateTo({
								url: '../pay/pay'
							})
						})

					}
				})
			},


		}
	}
</script>

<style scoped>
	.vaccine_detail {
		display: flex;
		height: 200rpx;
	}

	.vaccine_name {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 35rpx;
		background-color: #00CE47;

	}

	.vaccine_info {
		flex: 2;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: #b3b3b3;
	}

	.vaccine_price {
		font-size: 45rpx
	}

	.vaccine_date {
		margin-top: 10rpx;
		font-size: 22rpx;
	}

	.vaccine_submit {
		position: fixed;
		top: 50%;
		left: 50%;
		width: 300rpx;
		padding: 20rpx;
		text-align: center;
		border-radius: 12rpx;
		transform: translate(-50%, -50%);
		background-color: #ff557f;
		color: #fff;
	}
</style>
